//
//  HomepageViewController.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/7/19.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "HomepageViewController.h"
#import "CenterPageViewController.h"
#import "ExploreViewController.h"
#import "GoViewController.h"
#import "ShowmeViewController.h"
#import "CompetitionViewController.h"
@interface HomepageViewController ()<UITabBarDelegate>

@end

@implementation HomepageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor colorWithRed:(243)/255.0 green:(191)/255.0 blue:(66)/255.0 alpha:1.0f];
    view.frame = self.tabBar.bounds;
    [[UITabBar appearance] insertSubview:view atIndex:0];
    //     改变标题字体颜色和大小
    [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor blackColor]} forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor clearColor]} forState:UIControlStateSelected];
    [self createHomepageUI];
//    self.tabBarItem.accessibilityElementsHidden = NO;
}

-(void)createHomepageUI{
    CenterPageViewController *centerPageVc = [[CenterPageViewController alloc] init];
    ExploreViewController *explorevc = [[ExploreViewController alloc] init];
    GoViewController *goVc = [[GoViewController alloc] init];
    ShowmeViewController *showVc = [[ShowmeViewController alloc] init];
    CompetitionViewController *compeVc = [[CompetitionViewController alloc] init];
    UINavigationController *centerPageNav = [[UINavigationController alloc] initWithRootViewController:centerPageVc];
    UINavigationController *exploreNav = [[UINavigationController alloc] initWithRootViewController:explorevc];
    UINavigationController *goNav = [[UINavigationController alloc] initWithRootViewController:goVc];
//    UINavigationController *showNav = [[UINavigationController alloc] initWithRootViewController:showVc];
    UINavigationController *compeNav = [[UINavigationController alloc] initWithRootViewController:compeVc];
    centerPageNav.title = @"主页";
    exploreNav.title = @"秘探";
    goNav.title = @"走起";
    showVc.title = @"秀我";
    compeNav.title = @"我赛";
    exploreNav.tabBarItem.image = [[UIImage imageNamed:@"after1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    compeNav.tabBarItem.image = [[UIImage imageNamed:@"after2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    centerPageNav.tabBarItem.image = [[UIImage imageNamed:@"after3"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    goNav.tabBarItem.image = [[UIImage imageNamed:@"after4"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    showVc.tabBarItem.image = [[UIImage imageNamed:@"after5"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        exploreNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"fore1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        compeNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"fore2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        centerPageNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"fore3"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        goNav.tabBarItem.selectedImage = [[UIImage imageNamed:@"fore4"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        showVc.tabBarItem.selectedImage = [[UIImage imageNamed:@"fore5"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        exploreNav.tabBarItem.imageInsets = UIEdgeInsetsMake(3, 0, -3, 0);
        compeNav.tabBarItem.imageInsets = UIEdgeInsetsMake(3, 0, -3, 0);
        centerPageNav.tabBarItem.imageInsets = UIEdgeInsetsMake(3, 0, -3, 0);
        goNav.tabBarItem.imageInsets = UIEdgeInsetsMake(3, 0, -1, 0);
        showVc.tabBarItem.imageInsets = UIEdgeInsetsMake(3, 0, -3, 0);
    NSArray *array = [NSArray arrayWithObjects:exploreNav,compeNav,centerPageNav,goNav,showVc, nil];
    self.viewControllers = array;
    self.selectedIndex = 2;
//   [self.navigationController.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, 10)];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
